{% extends 'homepage.html' %}


{% block content %}

<style type="text/css">
table.ntdata th.left { 
    border-right: 2px solid #9b9; 
    background: #efe;
    border-bottom: 0;
    text-align: center;
}

table.ntdata th.weight {
  text-align: center;
  background: #efe;
  border-bottom: 2px solid #9b9;
  border-left: 0;
  vertical-align: center;
}

table.ntdata thead tr.space {
  background: #efe;
  border-bottom: 0;
}

table.ntdata thead th.spaceleft {
  border-right: 2px solid #9b9;
  vertical-align: top;
}
.modulus {
    vertical-align: top;
    padding-top:    .5em;
    padding-bottom: .5em;
    border-right: 2px solid #8a8;
}
.chi {
    padding: 5px 5px;
    width: 3em;
    float: left;
    display: inline;
    white-space:nowrap;
}
.chi a { display: inline; text-align: center; font-family: serif;}
#chitable { clear:right; }
#chitable td div { float: left; padding-left: .5em; padding-right: .5em; }
#chitable td div>a { text-align: right; }
#chitable td { vertical-align: middle;  white-space: nowrap; }
#chitable td.a { background: #DFD; }
#chitable td.b { background: none; }
#chitable th { text-align: center; }
table.ntdata tr.even, table.ntdata tr:nth-child(even) { background: none; }
table.ntdata tr.odd, table.ntdata tr:nth-child(odd), table.ntdata tr:first-child { background: none; }
#chitable .imprimitive a:visited { color:blue;}
#chitable .primitive   a:visited { color:green;}
#chitable .imprimitive { display:none; }
#chitable a { display: inline; }
#legend {
  margin: 0 20px 10px 0;
  border-left: 2px solid #006400;
}
#legend td { cursor: pointer; }

.primitive, .primitive a {
  color:green;
}
.imprimitive, .imprimitive a {
  color:blue;
}
</style>

{#<script type="text/javascript">
$(function() {
  var lastcols = $("#chitable tr th:last-child, #chitable tr td:last-child");
  lastcols.hide();
  $("#showlastcols").click(function () {
    lastcols.show("slow");
    $(this).hide();
  });
});
</script>
#}

<script type="text/javascript">
var prim = true;
var impr = false;
$(function() {
  $("#legend-imp").hover(
     function() { $(".imprimitive").css("background", "#DDF"); },
     function() { $(".imprimitive").css("background", "inherit"); }
     );
  $("#legend-imp").click(function() {
    impr = !impr;
    $("#chitable .imprimitive").toggle(impr);
    $("#legend-imp input").prop("checked", impr);
  });
  $("#legend-prim").click(function() {
    prim = !prim;
    $("#chitable .primitive").toggle(prim);
    $("#legend-prim input").prop("checked", prim);
  });
  $("#legend-prim").hover(
     function() { $(".primitive").css("background", "#90EE90"); },
     function() { $(".primitive").css("background", "inherit"); }
   );
 }
);
            
</script>

<table id="legend" style="float:right;">    
  <tr><td class="imprimitive" id="legend-imp"><input type="checkbox" /> Imprimitive</td></tr>
  <tr><td class="primitive" id="legend-prim"><input type="checkbox" checked /> Primitive</td></tr>
</table>

<div>
The table below displays {{ KNOWL('character.dirichlet', title="Dirichlet characters" ) }} of a 
given {{ KNOWL('character.dirichlet.modulus', title="modulus") }} \(q\) and index \(n\). If \(q\) is the 
{{ KNOWL('character.dirichlet.modulus', title="modulus") }}, then each integer \(n\) (on the \(q\)-th row)
represents the {{ KNOWL('character.dirichlet', title="Dirichlet character" ) }} \(\chi_{q}(n,&middot;)\). The 
characters are grouped with respect to order and stacked integers indicate (complex) conjugate characters.
</div>

<div>
<table class="ntdata" id="chitable">
    <thead class="space">
        <tr class="space">
            <th class="spaceleft"> Modulus </th>
            <th class="weight" colspan="{{headers|length}}">
                <span style ="display:block;float:left;margin-right:3px;"> Order </span></th>
        </tr>
        <th class="left"></th>
        {% for h in headers %}
        <th class="weight"> {{h}}</th>
        {% endfor %}
    </tr>
</thead>

{% macro show_character(entry, col, row) -%}
{% if not entry is none %}
<table><tr>
  {% if col == "more"  %}
    {% for e in entry %}
    <td class="{% if e[0][1] -%}primitive{%- else -%}imprimitive{%- endif %}">
      {% for chi in e %}
      <a href="{{url_for('render_Character', arg1=row, arg2=chi[0])}}" >{{ chi[0] }}</a>
      {% if loop.first %}<br/>{% endif %}
      {% endfor %}
    </td>
    {% endfor %}
  {% else %}
    {% for e in entry %}
    <td class="{% if e[0][1] -%}primitive{%- else -%}imprimitive{%- endif %}">
      {% for chi in e %}
        <a href="{{url_for('render_Character', arg1=row, arg2=chi[0])}}">{{ chi[0] }}</a>
      {% if loop.first %}<br/>{% endif %}
      {% endfor %}
    </td>
    {% endfor %}
  {% endif %}
</tr></table>
{% endif %}
{%- endmacro %}


{% set row_class = cycler('a', 'b') %}
<tbody>
{% for row in rows %}
  <tr>
  <th class="left"> {{ row }} </th>
   {% for col in cols %}
   <td class="{{ row_class.next() }}"> 
      {{ show_character(contents[(row, col)], col, row) }} 
   </td>
  {% endfor %}
  </tr>
{% endfor %}
<tbody>
</table>
</div>

{% endblock %}


